package com.example.yqand4v1_1.common.utils;

import io.agora.media.RtcTokenBuilder;
import io.agora.media.RtcTokenBuilder.Role;

public class RtcTokenBuilderSample {
    static String appId = "80725d6909ac496cae9ea4baed2d1759";
    static String appCertificate = "963a9e244bd947a290ddd8139ebfd8fc";
//    static String channelName = "ax";
    static String userAccount = "10101111";
    static int uid =0 ;
    static int expirationTimeInSeconds = 36850;

    public static String getToken(String channelName) throws Exception {
        RtcTokenBuilder token = new RtcTokenBuilder();
        int timestamp = (int)(System.currentTimeMillis() / 1000 + expirationTimeInSeconds);
//        String result = token.buildTokenWithUserAccount(appId, appCertificate,
//        		 channelName, userAccount, Role.Role_Admin, timestamp);
//        System.out.println(result);

        String result = token.buildTokenWithUid(appId, appCertificate,
       		 channelName, 0, Role.Role_Publisher, timestamp);
        System.out.println(result);
        return result;
    }
}
